import NoticeModel from '@/models/notice';
import noticeService from '@/services/noticeService';
import { action, computed, observable } from 'mobx';

export default class NoticeStore {

    @observable
    pageSize?: number = 5;
    @observable
    pageNumber?: number = 1;
    @observable
    noticeList?: Array<NoticeModel>;
    @observable
    noticeListLoading: boolean = false;
    @observable
    noticeInfo?: NoticeModel;
    @observable
    newsInfoLoading: boolean = false;
  
    @action
    async infoNotice(id: any) {
      this.newsInfoLoading = true;
      this.noticeInfo = (await noticeService.info(id)).dataInfo;
      this.newsInfoLoading = false;
    }
    @action
    async listNotice() {
        this.noticeListLoading = true;
        this.noticeList = (await noticeService.list(this.pageNumber, this.pageSize)).dataList;
        this.noticeListLoading = false;
        console.log(this.noticeList);

    }
}

export const noticeStore = new NoticeStore();
